package com.starry.JavaEEStudy;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;

public class RedirectServlet7 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setAttribute("requestkey1", "auto Requestkey1 attribute");
        getServletContext().setAttribute("contextKey1", "auto ServletContext attribute");
        //方法一
        //response.setStatus(302);
        //response.setHeader("Location","http://localhost:8080/javaeestudy/redirect8");
        //方法二 推荐
        response.sendRedirect("http://localhost:8080/javaeestudy/redirect8");
    }
}
